package com.ccloud.gen.engine.config;

import lombok.Data;

import java.util.ArrayList;
import java.util.List;

/**
 * @Version V1.0
 * @Project bigdata-cloud
 * @Title ControllerConfig
 * @Description 控制器模板生成的配置
 * @Package com.ccloud.gen.engine.config
 * @Date 2021/7/8 3:34 下午
 * @Copyright: 武汉大数据产业发展有限公司 All rights reserved.
 */
@Data
public class ControllerConfig {

    private ContextConfig contextConfig;

    private String controllerPathTemplate;
    private String packageName;//包名称
    private List<String> imports;//所引入的包

    public void init() {
        ArrayList<String> imports = new ArrayList<>();
        imports.add(contextConfig.getCoreBasePackage() + ".base.controller.BaseController");
        imports.add("org.springframework.stereotype.Controller");
        imports.add("org.springframework.web.bind.annotation.RequestMapping");
        imports.add("org.springframework.web.bind.annotation.ResponseBody");
        imports.add("org.springframework.ui.Model");
        imports.add("org.springframework.web.bind.annotation.PathVariable");
        imports.add("org.springframework.beans.factory.annotation.Autowired");
        imports.add(contextConfig.getProPackage() + ".core.log.LogObjectHolder");
        imports.add("org.springframework.web.bind.annotation.RequestParam");
        imports.add(contextConfig.getModelPackageName() + "." + contextConfig.getEntityName());
        imports.add(contextConfig.getProPackage() + "."+contextConfig.getBizPackageName()+"." + "." + contextConfig.getModuleName() + ".service" + ".I" + contextConfig.getEntityName() + "Service");
        this.imports = imports;
        this.packageName = contextConfig.getProPackage() + "."+contextConfig.getBizPackageName()+"." + contextConfig.getModuleName() + ".controller";
        this.controllerPathTemplate = "\\src\\main\\java\\" + contextConfig.getProPackage().replaceAll("\\.", "\\\\") + "\\" + contextConfig.getBizPackageName() + "\\modules\\" + contextConfig.getModuleName() + "\\controller\\{}Controller.java";
    }

}
